using MicroMsg.Common.Utils;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
namespace MicroMsg.UI.UserContrl
{
	public class GlittersService : ContentControl
	{
		private const string TAG = "GlittersService";
		private Storyboard GlittersStoryboard;
		private int GlittersCount;
		public static DependencyProperty ItemsOpacityProperty = DependencyProperty.Register("ItemsOpacity", typeof(double), typeof(GlittersService), new PropertyMetadata(1.0, new PropertyChangedCallback(GlittersService.OnItemPropertyChanged)));
		public double ItemsOpacity
		{
			get
			{
				return (double)base.GetValue(GlittersService.ItemsOpacityProperty);
			}
			set
			{
				base.SetValue(GlittersService.ItemsOpacityProperty, value);
			}
		}
		public Storyboard StartStoryboard()
		{
			if (this.GlittersStoryboard == null)
			{
				this.GlittersStoryboard = this.GetGlittersStoryboard();
			}
			if (this.GlittersCount <= 0)
			{
				this.GlittersStoryboard.Begin();
				Log.smethod_5("GlittersService", "GlittersStoryboard.Begin()");
			}
			this.GlittersCount++;
			return this.GlittersStoryboard;
		}
		public void EndStoryboard()
		{
			if (this.GlittersCount <= 0)
			{
				return;
			}
			this.GlittersCount--;
			if (this.GlittersCount == 0)
			{
				Log.smethod_5("GlittersService", "GlittersStoryboard.Stop()");
				this.GlittersStoryboard.Stop();
				this.GlittersStoryboard = null;
			}
		}
		private Storyboard GetGlittersStoryboard()
		{
			LinearDoubleKeyFrame linearDoubleKeyFrame = new LinearDoubleKeyFrame();
			linearDoubleKeyFrame.set_KeyTime(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.0)));
			linearDoubleKeyFrame.set_Value(1.0);
			LinearDoubleKeyFrame linearDoubleKeyFrame2 = new LinearDoubleKeyFrame();
			linearDoubleKeyFrame2.set_KeyTime(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1.0)));
			linearDoubleKeyFrame2.set_Value(0.2);
			LinearDoubleKeyFrame linearDoubleKeyFrame3 = new LinearDoubleKeyFrame();
			linearDoubleKeyFrame3.set_KeyTime(KeyTime.FromTimeSpan(TimeSpan.FromSeconds(2.0)));
			linearDoubleKeyFrame3.set_Value(1.0);
			DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
			doubleAnimationUsingKeyFrames.get_KeyFrames().Add(linearDoubleKeyFrame);
			doubleAnimationUsingKeyFrames.get_KeyFrames().Add(linearDoubleKeyFrame2);
			doubleAnimationUsingKeyFrames.get_KeyFrames().Add(linearDoubleKeyFrame3);
			doubleAnimationUsingKeyFrames.set_RepeatBehavior(RepeatBehavior.get_Forever());
			Storyboard.SetTarget(doubleAnimationUsingKeyFrames, this);
			Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames, new PropertyPath(GlittersService.ItemsOpacityProperty));
			Storyboard storyboard = new Storyboard();
			storyboard.get_Children().Add(doubleAnimationUsingKeyFrames);
			return storyboard;
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == GlittersService.ItemsOpacityProperty)
			{
				(dependencyObject_0 as GlittersService).OnItemsOpacityPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnItemsOpacityPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
		}
	}
}
